{include file="public/layout" /}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 
	<span class="c-gray en">&gt;</span> 管理员管理 
	<span class="c-gray en">&gt;</span> 权限资源列表 
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="page-container" style="margin-top: 20px;">
	<div class="cl pd-5 bg-1 bk-gray"> 
		<span class="l"> <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" href="/Admin/System/edit_right"><i class="Hui-iconfont">&#xe600;</i>权限资源管理</a> </span> <span class="r">共有数据：<strong>{$count}</strong> 条</span> </div>
	   <table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="6">权限资源管理</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox"></th>
				<th width="150">名称</th>
				<th width="100">资源类型</th>
				<th width="100">所属分组</th>
				<th width="500">权限码</th>
				<th width="70">操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach name="right_list" item="vo" key="k" }
			<tr class="text-c">
				<td><input type="checkbox" value="{$vo.id}" class="checkboxId"></td>
				<td>{$vo.name}</td>
				<td>系统后台</td>
				<td><a>{$group[$vo.group] ? $group[$vo.group] : '--'}</a></td>
				<td>{$vo.right}</td>
				<td class="f-14">
				<a title="编辑" href="/Admin/system/edit_right?id={$vo.id}&type={$vo.type}" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>
				</a>
				<a title="删除" href="javascript:;" onclick="admin_right_del(this)" class="ml-5" data-url="/Admin/system/right_del" data-id="{$vo.id}" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>
				</a>
			   </td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>
{include file="public/footer" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/public/h-ui.admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">
/*管理员-权限资源-删除*/
function admin_right_del(obj){
	layer.confirm('角色删除须谨慎，确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: $(obj).attr('data-url'),
			data:{del_id: $(obj).attr('data-id')},
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

//批量删除
function datadel() {
		var ids = '';
		var len = $(".checkboxId").length;
		for(var i = 0; i < len; i++) {
			var status = $(".checkboxId").eq(i).prop("checked");
			if(status == true) {
				var checkval = 1;
				ids+= ','+$(".checkboxId").eq(i).val();
			}
		}

		//至少选择一项目
		if(checkval == 1) {
			var ids = ids.substring(1);
			layer.confirm('确认要删除吗？',function(index){
				$.ajax({
						type: 'POST',
						url: '/Admin/system/delAll',
						data : {act:'delAll',ids:ids},
						dataType: 'json',
						success: function(data){
							layer.msg('已删除!',{icon:1,time:1000});
							setTimeout(function(){window.location.reload();}, 2000);
						},
						error:function(data) {
							console.log(data.msg);
						},
				});		
			});
		} else {
			layer.msg('至少选择一项目!',{icon:2,time:1000});
		}
	}
</script>
</body>
</html>